<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Title</title>
  </head>
  <body>
  
  </body>
  
  <script>
    /*var与let的区别*/
    /* **①作用范围不同**：`var`变量是全局范围，`let`变量是局部范围 */
    if (true) {
      var val1 = 5;
    }
    console.log(val1);
    if (true) {
      let val2 = 5;
    }
    //console.log(val2);
    /* **②顶置效果不同**：`var`变量支持顶置，`let`变量不支持 */
    varVal = 'varVal';
    alert(varVal);
    var varVal;
    
    /*letVal = 'letVal';
    alert(letVal);
    let letVal;*/
    /* **③重复声明效果不同**：`var`变量可使用相同变量名重复声明，`let`变量不支持 */
    var valVar = 'valVar1';
    var valVar = 'valVar2';
    
    let valLet = 'valLet1';
    //let valLet = 'valLet2';
    
    
    /*解构赋值*/
    var obj = {
      name: 'chen',
      age: 45,
      children: {
        name: 'jie',
        age: 12,
      }
    };
    //将obj对象中与变量名相同的属性的值赋值给该变量
    var {name, age, children: childrenAs} = obj;
    console.log(name + '  ' + age + '  ' + childrenAs);//chen  45  [object Object]
    
    var arr = [1, 2, 3];
    var [one, tow, three] = arr;
    console.log(one + '  ' + tow + '  ' + three);//1  2  3
    
    
    /*arguments*/
    {
      function funcArguments() {
        console.log(arguments);//Arguments(3) [1, 2, 3, callee: ƒ, Symbol(Symbol.iterator): ƒ]
        console.log(arguments.length);//3
        console.log(typeof arguments.callee);//function
        //arguments.callee();//funcArguments方法死循环
      }
      funcArguments(1, 2, 3);
    }
  </script>
</html>